home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Scripting 2882110132001.psc / clsSEX_Alias.cls next >
Encoding:
Visual Basic class definition  |  2001-10-13  |  26.8 KB  |  772 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsSSE_Alias"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. '* ********************
  15. '*     Alias Module
  16. '* ********************
  17.  
  18. Public rootEngine      As clsSSE_Main
  19.  
  20. '* Constants
  21. Private Const BEGIN_FUNCTION = "["
  22. Private Const END_FUNCTION = "]"
  23. Private Const BEGIN_SGROUP = "("
  24. Private Const END_SGROUP = ")"
  25. Private Const COMMENT_CHAR = ";"
  26. Private Const COMMENT_ML_CHAR = "#"
  27. Private Const PARAM_DELIM = " "
  28. Private Const BEGIN_VARLOCAL = "$"
  29. Private Const BEGIN_VARGLOBAL = "%"
  30. Private Const ESCAPE_CHAR = "\"
  31.  
  32.  
  33. Private currentLine As Integer
  34.  
  35. '* if stack
  36. Private stack_if()      As typIf
  37. Private stack_ifcount   As Integer
  38. Private Type typIf
  39.     bTrueYet    As Boolean
  40.     bNoEval     As Boolean
  41. End Type
  42.  
  43. '* while loop stack
  44. Private stack_while()       As typWhileLoop
  45. Private stack_whilecount    As Integer
  46. Private Type typWhileLoop
  47.     bIsFalse    As Boolean
  48.     iReturnLine As Integer
  49.     iLastLine   As Integer
  50.     bInit       As Boolean
  51. End Type
  52.  
  53. '* loop stack
  54. Private stack_loop()    As typLoop
  55. Private stack_loopcount As Integer
  56. Private Type typLoop
  57.     current As Long
  58.     total   As Long
  59.     linenum As Integer
  60.     varname As String
  61. End Type
  62.  
  63. '* Args
  64. Private Args()      As String
  65. Private ArgCount    As Integer
  66.  
  67. '* Var Type
  68. Private variableType As Integer
  69. Private Enum varType
  70.     LOCAL_
  71.     GLOBAL_
  72. End Enum
  73.  
  74. Public bInComment       As Boolean
  75. Public bGotoNextLine    As Boolean
  76. Public returnValue     As String
  77.  
  78. '* Alias Information
  79. Private strName         As String
  80. Private AliasType       As enAliasType
  81. Private strExtraParams  As String
  82. Private Enum enAliasType
  83.     at_ALIAS
  84.     at_EVENT
  85. End Enum
  86.  
  87. '* Local variables
  88. Private variables()     As typVariable
  89. Private varCount        As Integer
  90. Private Enum enumVarType
  91.     xString
  92.     xInteger
  93.     xReal
  94. End Enum
  95. Private Type typVariable
  96.     Name    As String
  97.     value() As String
  98.     type    As enumVarType
  99. End Type
  100.  
  101. '* Code storage
  102. Private strCode()       As String
  103. Private intCodeLines    As Integer
  104.  
  105. '* Call stack type
  106. Private Type typAliasCall
  107.     ArgCount    As Integer
  108.     Args()      As Variant
  109.     bQuote      As Boolean
  110. End Type
  111.  
  112. '* call stack
  113. Private stack_calls()       As typAliasCall
  114. Private stack_callcount     As Integer
  115.  
  116.  
  117. '* Execution multiplier
  118. Private em_total    As Integer
  119. Private em_current  As Integer
  120.  
  121. Public Sub AddCodeLine(strCodeLine As String)
  122.     intCodeLines = intCodeLines + 1
  123.     ReDim Preserve strCode(1 To intCodeLines) As String
  124.     strCode(intCodeLines) = strCodeLine
  125. End Sub
  126.  
  127.  
  128. Private Sub AddLocalVar(strVarNameX As String, strValue As String, Optional arrayElement As Integer = 0, Optional tvType As Integer = 0)
  129.     varCount = varCount + 1
  130.     ReDim Preserve variables(1 To varCount) As typVariable
  131.     variables(varCount).Name = strVarNameX
  132.     ReDim variables(varCount).value(arrayElement) As String
  133.     variables(varCount).value(arrayElement) = strValue
  134.     variables(varCount).type = LOCAL_
  135. End Sub
  136.  
  137. Private Sub CleanUp()
  138.     On Error Resume Next
  139.     
  140.     ReDim stack_calls(0) As typAliasCall
  141.     stack_callcount = 0
  142.     ReDim stack_calls(0).Args(0)
  143.     stack_calls(0).ArgCount = 0
  144.     
  145. End Sub
  146.  
  147.  
  148.  
  149. Public Sub CopyAlias(ByRef oldAliasClass As clsSSE_Alias, ByRef newAliasClass As clsSSE_Alias)
  150.     Set newAliasClass = oldAliasClass
  151. End Sub
  152.  
  153. Private Sub CopyToArgs(paramlist())
  154.     If UBound(paramlist) = 0 Then
  155.         ReDim Args(0) As String
  156.         ArgCount = 0
  157.         Exit Sub
  158.     End If
  159.     
  160.     ReDim Args(UBound(paramlist)) As String
  161.     ArgCount = UBound(paramlist) + 1
  162.     
  163.     Dim i As Integer
  164.     For i = LBound(paramlist) To UBound(paramlist)
  165.         Args(i) = paramlist(i)
  166.     Next i
  167. End Sub
  168.  
  169. Public Sub dev_evalaliasx()
  170.     Dim i As Integer, strInfo As String, strAliasType, paramlist(), strParamList() As String
  171.     
  172.     i = 1
  173.     If AliasType = at_ALIAS Then strAliasType = "Alias"
  174.     If AliasType = at_EVENT Then strAliasType = "Event"
  175.     strInfo = "Alias Name:   " & strName & vbCrLf & _
  176.               "Alias Type:   " & strAliasType & vbCrLf & _
  177.               "Extra Params: " & strExtraParams & vbCrLf & vbCrLf
  178.     For i = 1 To intCodeLines
  179.         strInfo = strInfo & i & ":  " & strCode(i) & vbCrLf
  180.     Next i
  181.     
  182.     'MsgBox strInfo
  183.     strParamList = Split(strExtraParams, " ")
  184.     If UBound(strParamList) > 0 Then
  185.         ReDim paramlist(UBound(strParamList))
  186.         For i = LBound(strParamList) To UBound(strParamList)
  187.             paramlist(i) = strParamList(i)
  188.         Next i
  189.     End If
  190.         
  191.     rootEngine.ExecuteAlias strName, paramlist
  192. End Sub
  193.  
  194.  
  195. Public Function Execute(paramlist()) As String
  196.     Dim bFinished As Boolean
  197.     currentLine = 1
  198.     bGotoNextLine = True
  199.     bInComment = False
  200.     
  201.     CopyToArgs paramlist
  202.     ReDim stack_while(0) As typWhileLoop
  203.         
  204.     Do
  205.         Call CleanUp
  206.         If currentLine = 0 Then
  207.             Execute = ""
  208.             Exit Function
  209.         End If
  210.         returnValue = ExecuteLine(strCode(currentLine))
  211.                 
  212.         If bGotoNextLine Then
  213.             currentLine = currentLine + 1
  214.         End If
  215.     Loop Until currentLine > intCodeLines Or bGotoNextLine = False
  216.     'MsgBox returnValue & "~~"
  217.     Execute = returnValue
  218. End Function
  219.  
  220. Public Function ExecuteLine(strLine As String)
  221.     '*
  222.     '* This is the heart of SEX
  223.     '*
  224.  
  225.     'On Error Resume Next
  226.  
  227.     Dim strBuffer As String, i As Integer, curChar As String, prevChar As String
  228.     Dim inVariable As Boolean, bEscape As Boolean, strLen As String, bWhiteSpace As Boolean
  229.     strLen = Len(strLine)
  230.     
  231.     '* Clean stacks
  232.     CleanUp
  233.     
  234.     i = 1
  235.     
  236.     If stack_whilecount <= UBound(stack_while) Then
  237.         If stack_while(stack_whilecount).bIsFalse And Left(strLine, 3) <> "end" Then
  238.             Exit Function
  239.         End If
  240.     End If
  241.     
  242.     Do Until i > strLen
  243.         curChar = Mid(strLine, i, 1)
  244.         
  245.         If prevChar <> ESCAPE_CHAR Then
  246.             If curChar = COMMENT_ML_CHAR Then
  247.                 bWhiteSpace = False
  248.                 bInComment = Not bInComment
  249.             End If
  250.             If bInComment Or curChar = COMMENT_ML_CHAR Then GoTo nextchar
  251.         End If
  252.         
  253.         '* Append escape char
  254.         If bEscape Then
  255.             bWhiteSpace = False
  256.             'if invar, end var
  257.             If inVariable Then
  258.                 '* change this...
  259.                 stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  260.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  261.                 strBuffer = ""
  262.                 inVariable = False
  263.             End If
  264.             Dim strEscapeChar As String
  265.             
  266.             strEscapeChar = GetEscapeChar(curChar)
  267.             
  268.             stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  269.                 stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & strEscapeChar
  270.             bEscape = False
  271.             
  272.         '* Comments, end
  273.         ElseIf curChar = COMMENT_CHAR Then
  274.             bWhiteSpace = False
  275.             '* if invar, end var
  276.             If inVariable Then
  277.                 '* change this...
  278.                 stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  279.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetLocalVar(strBuffer)
  280.  
  281.                 strBuffer = ""
  282.                 inVariable = False
  283.             End If
  284.             
  285.             GoTo finish
  286.         '* Other stuff..parse
  287.         Else
  288.         
  289.         Select Case curChar
  290.             Case ESCAPE_CHAR
  291.                 bWhiteSpace = False
  292.                 '* if invar, end var
  293.                 If inVariable Then
  294.                     '* change this...
  295.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  296.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  297.                     strBuffer = ""
  298.                     inVariable = False
  299.                 End If
  300.                 
  301.                 If bEscape Then
  302.                     '* get var, add escape
  303.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  304.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & "\"
  305.                 
  306.                 End If
  307.                 
  308.                 bEscape = True
  309.             Case BEGIN_FUNCTION
  310.                 bWhiteSpace = False
  311.                 '* if invar, end var
  312.                 If inVariable Then
  313.                     '* change this...
  314.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  315.                     strBuffer = ""
  316.                     inVariable = False
  317.                 End If
  318.             
  319.                 stack_callcount = stack_callcount + 1
  320.                 ReDim Preserve stack_calls(stack_callcount) As typAliasCall
  321.                 ReDim stack_calls(stack_callcount).Args(0) As Variant
  322.                 stack_calls(stack_callcount).ArgCount = 0
  323.                 
  324.             Case END_FUNCTION
  325.                 bWhiteSpace = False
  326.                 '* if invar, end var
  327.                 If inVariable Then
  328.                     '* change this...
  329.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  330.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  331.                         
  332.                     strBuffer = ""
  333.                     inVariable = False
  334.                 End If
  335.                 
  336.                 Dim strReturnVal As String
  337.                 If stack_callcount = 0 Then GoTo nextchar
  338.                 
  339.                 If Left(CStr(stack_calls(stack_callcount).Args(0)), 1) = "$" Then
  340.                     If stack_calls(stack_callcount).ArgCount < 1 Then
  341.                         strReturnVal = ""
  342.                         GoTo skipFunction
  343.                     End If
  344.                     
  345.                     strReturnVal = GetLocalVar(Mid(CStr(stack_calls(stack_callcount).Args(0)), 2), CInt(stack_calls(stack_callcount).Args(1)))
  346.                     GoTo skipFunction
  347.                 End If
  348.                 
  349.                             
  350.                 Set rootEngine.cChildAlias = Me
  351.                 strReturnVal = rootEngine.ExecuteAlias(CStr(stack_calls(stack_callcount).Args(0)), stack_calls(stack_callcount).Args)
  352. skipFunction:
  353.                 stack_calls(stack_callcount).ArgCount = 0
  354.                 stack_callcount = stack_callcount - 1
  355.                 stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & strReturnVal
  356.                 
  357.             Case PARAM_DELIM
  358.                 If bWhiteSpace = True Then GoTo nextchar
  359.                 
  360.                 '* if invar, end var
  361.                 If inVariable Then
  362.                     '* change this...
  363.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  364.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  365.                     
  366.                     strBuffer = ""
  367.                     inVariable = False
  368.                 End If
  369.                 
  370.                 If stack_calls(stack_callcount).bQuote Then
  371.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  372.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & PARAM_DELIM
  373.                 Else
  374.                     stack_calls(stack_callcount).ArgCount = stack_calls(stack_callcount).ArgCount + 1
  375.                     ReDim Preserve stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount)
  376.                 End If
  377.             Case """"
  378.                 bWhiteSpace = False
  379.                 
  380.                 stack_calls(stack_callcount).bQuote = _
  381.                     Not stack_calls(stack_callcount).bQuote
  382.  
  383.             Case BEGIN_VARLOCAL
  384.                 bWhiteSpace = False
  385.                 If prevChar = BEGIN_FUNCTION Then
  386.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  387.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & "$"
  388.                     GoTo nextchar
  389.                 End If
  390.                 
  391.                 '* if invar, end var
  392.                 If inVariable Then
  393.                     '* change this...
  394.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  395.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  396.                     
  397.                     strBuffer = ""
  398.                     inVariable = False
  399.                 End If
  400.                 variableType = 1
  401.                 inVariable = True
  402.                 strBuffer = ""
  403.             Case BEGIN_VARGLOBAL
  404.                 bWhiteSpace = False
  405.                 variableType = 2
  406.                 inVariable = True
  407.                 strBuffer = ""
  408.             Case Else
  409.                 bWhiteSpace = False
  410.                 If inVariable Then
  411.                     '* In variable, append to strbuffer
  412.                     Select Case curChar
  413.                         Case "?", ",", ".", "/", "!", "@"
  414.                             '* change this...
  415.                             stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  416.                                 stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  417.                             
  418.                             strBuffer = ""
  419.                             inVariable = False
  420.  
  421.                             stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  422.                                 stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & curChar
  423.                         
  424.                         Case "}", ">"
  425.                             strBuffer = strBuffer & curChar
  426.                             '* change this...
  427.                             stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  428.                                 stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  429.  
  430.                             strBuffer = ""
  431.                             inVariable = False
  432.                         Case Else
  433.                             strBuffer = strBuffer & curChar
  434.                     End Select
  435.                 Else
  436.                     '* Else append to other shit..
  437.                     stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = _
  438.                         stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & curChar
  439.                     
  440.                 End If
  441.         End Select
  442.                         
  443.         End If
  444. nextchar:
  445.     
  446.         prevChar = curChar
  447.         i = i + 1
  448.     Loop
  449.     
  450.     If strBuffer <> "" Then
  451.         If inVariable Then
  452.             '* change this...
  453.             stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) = stack_calls(stack_callcount).Args(stack_calls(stack_callcount).ArgCount) & GetVar(strBuffer)
  454.  
  455.             strBuffer = ""
  456.             inVariable = False
  457.         End If
  458.     End If
  459.     
  460. finish:
  461.  
  462.     Dim strReturn As String
  463.     
  464.     
  465.     If stack_calls(0).Args(0) = "return" Then
  466.         If UBound(stack_while) >= stack_whilecount Then
  467.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  468.         End If
  469.         If stack_ifcount > 0 Then
  470.             If stack_if(stack_ifcount).bTrueYet = False Then Exit Function
  471.         End If
  472.         '*
  473.         '* return statement
  474.         '*
  475.         ExecuteLine = JoinArrayV(stack_calls(0).Args, " ", 2)
  476.         bGotoNextLine = False
  477.         Exit Function
  478.     ElseIf stack_calls(0).Args(0) = "set" Then
  479.         If UBound(stack_while) >= stack_whilecount Then
  480.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  481.         End If
  482.         If stack_ifcount > 0 Then
  483.             If stack_if(stack_ifcount).bTrueYet = False Then Exit Function
  484.         End If
  485.         '*
  486.         '* set a variable
  487.         '*
  488.         If UBound(stack_calls(0).Args) < 2 Then Exit Function
  489.         
  490.         If CStr(stack_calls(0).Args(1)) Like "*:*" Then
  491.             SetLocalVar CStr(Mid(CStr(stack_calls(0).Args(1)), 1, InStr(CStr(stack_calls(0).Args(1)), ":") - 1)), JoinArrayV(stack_calls(0).Args, " ", 3), Mid(CStr(stack_calls(0).Args(1)), InStr(CStr(stack_calls(0).Args(1)), ":") + 1)
  492.         Else
  493.             SetLocalVar CStr(stack_calls(0).Args(1)), JoinArrayV(stack_calls(0).Args, " ", 3)
  494.         End If
  495.     
  496.     '*
  497.     '* WHILE LOOP
  498.     '*
  499.     ElseIf stack_calls(0).Args(0) = "while" Then
  500.         If stack_whilecount <= UBound(stack_while) Then
  501.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  502.         End If
  503.         If stack_ifcount > 0 Then
  504.             If stack_if(stack_ifcount).bTrueYet = False Then Exit Function
  505.         End If
  506.         
  507.         If UBound(stack_calls(0).Args) < 1 Then Exit Function
  508.         
  509.         stack_whilecount = stack_whilecount + 1
  510.         If stack_whilecount > UBound(stack_while) Then ReDim Preserve stack_while(stack_whilecount) As typWhileLoop
  511.         
  512.         If stack_while(stack_whilecount).bInit = False Then
  513.             stack_while(stack_whilecount).iReturnLine = currentLine
  514.             stack_while(stack_whilecount).bInit = True
  515.             stack_while(stack_whilecount).bIsFalse = False
  516.         End If
  517.         
  518.         Dim whileStat
  519.         whileStat = Eval(JoinArrayV(stack_calls(0).Args, " ", 2))
  520.         
  521.         If whileStat <> 0 Then
  522.             stack_while(stack_whilecount).bIsFalse = False
  523.             stack_while(stack_whilecount).iReturnLine = currentLine
  524.         Else
  525.             stack_while(stack_whilecount).bIsFalse = True
  526.             If stack_while(stack_whilecount).iLastLine <> -1 Then
  527.                 currentLine = stack_while(stack_whilecount).iLastLine
  528.                 Exit Function
  529.             End If
  530.         End If
  531.         
  532.     ElseIf stack_calls(0).Args(0) = "loop" Then
  533.         If UBound(stack_while) >= stack_whilecount Then
  534.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  535.         End If
  536.         If stack_ifcount > 0 Then
  537.             If stack_if(stack_ifcount).bTrueYet = False Then Exit Function
  538.         End If
  539.         
  540.         If UBound(stack_calls(0).Args) < 2 Then Exit Function
  541.         
  542.         stack_loopcount = stack_loopcount + 1
  543.         ReDim Preserve stack_loop(stack_loopcount) As typLoop
  544.     
  545.         stack_loop(stack_loopcount).current = 1
  546.         stack_loop(stack_loopcount).total = stack_calls(0).Args(2)
  547.         stack_loop(stack_loopcount).linenum = currentLine '+ 1
  548.         stack_loop(stack_loopcount).varname = stack_calls(0).Args(1)
  549.         SetLocalVar stack_loop(stack_loopcount).varname, "1"
  550.  
  551.     ElseIf stack_calls(0).Args(0) = "if" Then
  552.         If UBound(stack_while) >= stack_whilecount Then
  553.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  554.         End If
  555.         If UBound(stack_calls(0).Args) < 1 Then Exit Function
  556.         
  557.         stack_ifcount = stack_ifcount + 1
  558.         ReDim Preserve stack_if(stack_ifcount) As typIf
  559.         
  560.         Dim ifStat
  561.         ifStat = Eval(JoinArrayV(stack_calls(0).Args, " ", 2))
  562.        
  563.         If ifStat = 0 Then
  564.             stack_if(stack_ifcount).bTrueYet = False
  565.         Else
  566.             stack_if(stack_ifcount).bTrueYet = True
  567.         End If
  568.     ElseIf stack_calls(0).Args(0) = "elseif" Then
  569.         '* if in while loop, damnit!
  570.         If UBound(stack_while) >= stack_whilecount Then
  571.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  572.         End If
  573.         
  574.         If stack_if(stack_ifcount).bNoEval = True Then Exit Function
  575.         If stack_if(stack_ifcount).bTrueYet = True Then
  576.             stack_if(stack_ifcount).bTrueYet = False
  577.             stack_if(stack_ifcount).bNoEval = True
  578.             Exit Function
  579.         End If
  580.         
  581.         If UBound(stack_calls(0).Args) < 1 Then Exit Function
  582.         
  583.         Dim ifStat2
  584.         ifStat2 = Eval(JoinArrayV(stack_calls(0).Args, " ", 2))
  585.         
  586.         If ifStat2 = 0 Then
  587.             stack_if(stack_ifcount).bTrueYet = False
  588.         Else
  589.             stack_if(stack_ifcount).bTrueYet = True
  590.         End If
  591.     ElseIf stack_calls(0).Args(0) = "else" Then
  592.         '* if in while loop, damnit!
  593.         If UBound(stack_while) >= stack_whilecount Then
  594.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  595.         End If
  596.         
  597.         If stack_if(stack_ifcount).bNoEval = True Then Exit Function
  598.         If stack_if(stack_ifcount).bTrueYet = True Then
  599.             stack_if(stack_ifcount).bTrueYet = False
  600.             stack_if(stack_ifcount).bNoEval = True
  601.             Exit Function
  602.         End If
  603.         
  604.         stack_if(stack_ifcount).bTrueYet = True
  605.     '*
  606.     '* init variables
  607.     '*
  608.     ElseIf stack_calls(0).Args(0) = "init" Then
  609.         Dim iLoop As Integer
  610.         For iLoop = 1 To stack_calls(0).ArgCount - 1
  611.             AddLocalVar CStr(stack_calls(0).Args(iLoop)), "0"
  612.         Next iLoop
  613.     '*
  614.     '* END
  615.     '*
  616.     ElseIf stack_calls(0).Args(0) = "end" Then
  617.     
  618.         If stack_calls(0).ArgCount < 1 Then Exit Function
  619.         
  620.         Select Case stack_calls(0).Args(1)
  621.             Case "loop"
  622.                 If stack_ifcount > 0 Then
  623.                     If stack_if(stack_ifcount).bTrueYet = False Then Exit Function
  624.                 End If
  625.  
  626.                 stack_loop(stack_loopcount).current = stack_loop(stack_loopcount).current + 1
  627.                 If stack_loop(stack_loopcount).current > stack_loop(stack_loopcount).total Then
  628.                     stack_loopcount = stack_loopcount - 1
  629.                 Else
  630.                     currentLine = stack_loop(stack_loopcount).linenum
  631.                 End If
  632.                 SetLocalVar stack_loop(stack_loopcount).varname, CStr(stack_loop(stack_loopcount).current)
  633.  
  634.             Case "if"
  635.                 stack_ifcount = stack_ifcount - 1
  636.             Case "while"
  637.                 If stack_while(stack_whilecount).bIsFalse Then
  638.                     stack_while(stack_whilecount).bInit = False
  639.                     stack_while(stack_whilecount).bIsFalse = False
  640.                     stack_whilecount = stack_whilecount - 1
  641.                     stack_while(stack_whilecount).iLastLine = -1
  642.                 Else
  643.                     stack_whilecount = stack_whilecount - 1
  644.                     currentLine = stack_while(stack_whilecount + 1).iReturnLine - 1
  645.                     stack_while(stack_whilecount + 1).iLastLine = currentLine
  646.                 End If
  647.         End Select
  648.     Else
  649.         If stack_ifcount > 0 Then
  650.             If stack_if(stack_ifcount).bTrueYet = False Then Exit Function
  651.         End If
  652.         
  653.         '* if in while loop, damnit!
  654.         If UBound(stack_while) >= stack_whilecount Then
  655.             If stack_while(stack_whilecount).bIsFalse Then Exit Function
  656.         End If
  657.         
  658.         '*
  659.         '* nothing special, call the alias
  660.         '*
  661.         strReturn = rootEngine.ExecuteAlias(CStr(stack_calls(0).Args(0)), stack_calls(0).Args)
  662.     End If
  663.     
  664.     ExecuteLine = ""
  665.  
  666. End Function
  667.  
  668.  
  669. Private Function GetEscapeChar(strChar As String) As String
  670.     Select Case strChar
  671.         Case "n"    'new line
  672.             GetEscapeChar = vbCrLf
  673.         Case "t"    'tab
  674.             GetEscapeChar = Chr(9)
  675.         Case "0"    'char 0
  676.             GetEscapeChar = Chr(0)
  677.         Case "1"    'char 1
  678.             GetEscapeChar = Chr(1)
  679.         Case "c"    'color char
  680.             GetEscapeChar = Chr(3)
  681.         Case "r"    'reverse char
  682.             GetEscapeChar = Chr(22)
  683.         Case "b"    'bold char
  684.             GetEscapeChar = Chr(2)
  685.         Case "u"    'underline char
  686.             GetEscapeChar = Chr(31)
  687.         
  688.         Case Else
  689.             GetEscapeChar = strChar
  690.     End Select
  691. End Function
  692.  
  693.  
  694. Public Function GetLocalVar(strVarName As String, Optional arrayElement As Integer = 0) As String
  695.     Dim i As Integer
  696.     For i = 1 To varCount
  697.         'MsgBox strVarName & "~" & variables(i).Name
  698.         If variables(i).Name = strVarName Then
  699.             If arrayElement > UBound(variables(i).value) Then
  700.                 GetLocalVar = ""
  701.             Else
  702.                 GetLocalVar = variables(i).value(arrayElement)
  703.             End If
  704.             Exit Function
  705.         End If
  706.     Next i
  707.     GetLocalVar = ""
  708. End Function
  709.  
  710. Public Function GetName() As String
  711.     GetName = strName
  712. End Function
  713.  
  714.  
  715.  
  716. Private Function GetVar(strVarName As String) As String
  717.     If (Left(strVarName, 1) = "{" And Right(strVarName, 1) = "}") Or (Left(strVarName, 1) = "<" And Right(strVarName, 1) = ">") Then
  718.         strVarName = Mid(strVarName, 2, Len(strVarName) - 2)
  719.     End If
  720.     
  721.     
  722.     If Right(strVarName, 1) = "-" Then
  723.         If IsNumeric(Left(strVarName, Len(strVarName) - 1)) Then
  724.             GetVar = JoinArray(Args, " ", Left(strVarName, Val(Len(strVarName) - 1)) + 1)
  725.             Exit Function
  726.         End If
  727.     End If
  728.     
  729.     If IsNumeric(strVarName) Then
  730.         If Val(strVarName) > ArgCount Then
  731.             GetVar = ""
  732.         Else
  733.             GetVar = Args(strVarName)
  734.         End If
  735.         Exit Function
  736.     End If
  737.     
  738.     
  739.     If variableType = 1 Then
  740.         GetVar = GetLocalVar(strVarName)
  741.     Else
  742.         '*get global var
  743.         
  744.         ' finish code
  745.         GetVar = rootEngine.GetGlobalVar(strVarName)
  746.     End If
  747. End Function
  748.  
  749. Public Sub SetInfo(strtheName As String, at As Integer, strtheExtraParams As String)
  750.     strName = strtheName
  751.     AliasType = at
  752.     strExtraParams = strtheExtraParams
  753. End Sub
  754.  
  755.  
  756. Public Sub SetLocalVar(strVarName As String, strValue As String, Optional arrayElement As Integer = 0)
  757.     Dim i As Integer
  758.     
  759.     For i = 1 To varCount
  760.         
  761.         If variables(i).Name = strVarName Then
  762.             If arrayElement > UBound(variables(i).value) Then ReDim Preserve variables(i).value(arrayElement) As String
  763.             variables(i).value(arrayElement) = strValue
  764.             Exit Sub
  765.         End If
  766.     Next i
  767.     
  768.     AddLocalVar strVarName, strValue, arrayElement
  769. End Sub
  770.  
  771.  
  772.